package com.wzdigit.wms.wms.controller.common;

import com.wzdigit.framework.RandomlyThrowsException;
import com.wzdigit.framework.exception.RestStatusException;
import com.wzdigit.framework.model.response.ErrorEntity;
import com.wzdigit.wms.basic.enums.*;
import com.wzdigit.wms.wms.constant.WmsWareConstant;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

@Slf4j
@RestController
@Api(tags = "发货单相关参数枚举控制层")
@RequestMapping(value = WmsWareConstant.API_VERSION)
public class GdnEnumController {
	
    public static final String REQUSET_MODEL = "/sys/common/gdnenum";

    @RandomlyThrowsException
    @ApiOperation(value = "发货单表头状态", notes = "发货单表头状态")
    @ApiResponses({@ApiResponse(code = 500, message = "系统异常", response = ErrorEntity.class)})
    @GetMapping(value = REQUSET_MODEL + "/getGdnHeaderStatusEnum")
    public Map<Integer, String> getGdnHeaderStatusEnum(
            HttpServletRequest servletRequest, 
            HttpServletResponse servletResponse) {
        try {
            return GdnHeaderStatusEnum.getEnumByDescription();
        } catch (RestStatusException ex) {
            servletResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            throw ex;
        }
    }
    
    @RandomlyThrowsException
    @ApiOperation(value = "发货单单据类型", notes = "发货单单据类型")
    @ApiResponses({@ApiResponse(code = 500, message = "系统异常", response = ErrorEntity.class)})
    @GetMapping(value = REQUSET_MODEL + "/getGdnTypeEnum")
    public Map<String, String> getGdnTypeEnum(
            HttpServletRequest servletRequest, 
            HttpServletResponse servletResponse) {
        try {
            return GdnTypeEnum.getEnumByDescription();
        } catch (RestStatusException ex) {
            servletResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            throw ex;
        }
    }
    
    @RandomlyThrowsException
    @ApiOperation(value = "发货单销售类型", notes = "发货单销售类型")
    @ApiResponses({@ApiResponse(code = 500, message = "系统异常", response = ErrorEntity.class)})
    @GetMapping(value = REQUSET_MODEL + "/getGdnHeaderSaleTypeEnum")
    public Map<Integer, String> getGdnHeaderSaleTypeEnum(
            HttpServletRequest servletRequest, 
            HttpServletResponse servletResponse) {
        try {
            return GdnHeaderSaleTypeEnum.getEnumByDescription();
        } catch (RestStatusException ex) {
            servletResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            throw ex;
        }
    }
    
    @RandomlyThrowsException
    @ApiOperation(value = "发货单明细状态", notes = "发货单明细状态")
    @ApiResponses({@ApiResponse(code = 500, message = "系统异常", response = ErrorEntity.class)})
    @GetMapping(value = REQUSET_MODEL + "/getGdnDtlStatusEnum")
    public Map<Integer, String> getGdnDtlStatusEnum(
            HttpServletRequest servletRequest, 
            HttpServletResponse servletResponse) {
        try {
            return GdnDtlStatusEnum.getEnumByDescription();
        } catch (RestStatusException ex) {
            servletResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            throw ex;
        }
    }
    
    @RandomlyThrowsException
    @ApiOperation(value = "拣货任务生成标记", notes = "拣货任务生成标记")
    @ApiResponses({@ApiResponse(code = 500, message = "系统异常", response = ErrorEntity.class)})
    @GetMapping(value = REQUSET_MODEL + "/getGdnDtlPickTaskFlagEnum")
    public Map<Integer, String> getGdnDtlPickTaskFlagEnum(
            HttpServletRequest servletRequest, 
            HttpServletResponse servletResponse) {
        try {
            return GdnDtlPickTaskFlagEnum.getEnumByDescription();
        } catch (RestStatusException ex) {
            servletResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            throw ex;
        }
    }
    
    @RandomlyThrowsException
    @ApiOperation(value = "发货单预配状态", notes = "发货单预配状态")
    @ApiResponses({@ApiResponse(code = 500, message = "系统异常", response = ErrorEntity.class)})
    @GetMapping(value = REQUSET_MODEL + "/getGdnPreAlocStatusEnum")
    public Map<Integer, String> getGdnPreAlocStatusEnum(
            HttpServletRequest servletRequest, 
            HttpServletResponse servletResponse) {
        try {
            return DocPreAlocStatusEnum.getEnumByDescription();
        } catch (RestStatusException ex) {
            servletResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            throw ex;
        }
    }
    
    @RandomlyThrowsException
    @ApiOperation(value = "拣货任务状态", notes = "拣货任务状态")
    @ApiResponses({@ApiResponse(code = 500, message = "系统异常", response = ErrorEntity.class)})
    @GetMapping(value = REQUSET_MODEL + "/getPicktaskStatusEnum")
    public Map<Integer, String> getPicktaskStatusEnum(
            HttpServletRequest servletRequest, 
            HttpServletResponse servletResponse) {
        try {
            return PicktaskStatusEnum.getEnumByDescription();
        } catch (RestStatusException ex) {
            servletResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            throw ex;
        }
    }
    
    @RandomlyThrowsException
    @ApiOperation(value = "打印标识", notes = "打印标识")
    @ApiResponses({@ApiResponse(code = 500, message = "系统异常", response = ErrorEntity.class)})
    @GetMapping(value = REQUSET_MODEL + "/getPrintFlagEnum")
    public Map<Integer, String> getPrintFlagEnum(
            HttpServletRequest servletRequest, 
            HttpServletResponse servletResponse) {
        try {
            return PrintFlagEnum.getEnumByDescription();
        } catch (RestStatusException ex) {
            servletResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            throw ex;
        }
    }
    
    @RandomlyThrowsException
    @ApiOperation(value = "装柜单状态", notes = "装柜单状态")
    @ApiResponses({@ApiResponse(code = 500, message = "系统异常", response = ErrorEntity.class)})
    @GetMapping(value = REQUSET_MODEL + "/getCtnrLoadingStatusEnum")
    public Map<Integer, String> getCtnrLoadingStatusEnum(
            HttpServletRequest servletRequest, 
            HttpServletResponse servletResponse) {
        try {
            return CtnrLoadingStatusEnum.getEnumByDescription();
        } catch (RestStatusException ex) {
            servletResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            throw ex;
        }
    }
}
